execute if items entity @s weapon.mainhand *[!damage~{durability:{min:1}}] run return fail

execute unless data entity @s SelectedItem.components."minecraft:custom_data".powerSwordAttribute run return fail

summon armor_stand ~ ~ ~ {Tags:[tempRemoveDaggerAttribute],Invisible:true,Invulnerable:true,Marker:true}

item replace entity @n[tag=tempRemoveDaggerAttribute,distance=..30,type=armor_stand] weapon.mainhand from entity @s weapon.mainhand
data modify entity @n[tag=tempRemoveDaggerAttribute,distance=..30,type=armor_stand] HandItems[0].components."minecraft:attribute_modifiers" set from entity @n[tag=tempRemoveDaggerAttribute,distance=..30,type=armor_stand] HandItems[0].components."minecraft:custom_data".powerSwordAttribute
data remove entity @n[tag=tempRemoveDaggerAttribute,distance=..30,type=armor_stand] HandItems[0].components."minecraft:custom_data".powerSwordAttribute
item replace entity @s weapon.mainhand from entity @n[tag=tempRemoveDaggerAttribute,distance=..30,type=armor_stand] weapon.mainhand

kill @n[tag=tempRemoveDaggerAttribute,distance=..30,type=armor_stand]